<?php if($this->isChoMuon) ?>
<script>
    document.getElementById('finder').style.display = "";
    document.getElementById('hard_content').style.display = "";
    document.getElementById('main_content').style.display = "none";
    jx.setOuterForm(document.frmSearch);
    common.setMainTitle('Trang tìm kiếm');
</script>
<div style="width=300px;heigh=300px;float:left;padding-right:10px;">
<form id="mainform" action="">
    <?php
    //var_dump($this->data);exit;
    $arrSearch = split(" ",$this->search);
    if(count($this->data) > 0)
    {
    foreach($this->data as $row) { ?>
    <table border="0" width="600px" cellpadding="0" cellspacing="0">
    <tr class="search-results">
       <td class="search-results-title">
        <a href="javascript:"><?php
        $strReplace = mb_strtolower($row['TEN'],"utf-8");
        for($i=0;$i<count($arrSearch);$i++){
        $strReplace = str_replace(mb_strtolower($arrSearch[$i],"utf-8"), '<em>'.$arrSearch[$i].'</em>', $strReplace);
        }
        echo $strReplace;
        ?>
        </a>
       </td>     
    </tr>
    <tr>
        <td class="search-results-gadget">
            <u>Mã</u> : <?=$row['MA']?>
            - <u>Tác giả</u> : <?=$row['TACGIA']?>
            - <u>Lĩnh vực</u> : <?=$row['DANHMUC']?>
            - <u>Nhà XB</u> : <?=$row['NHAXB']?>
        </td>
    </tr> 
<!--    <tr >
       <td class="search-results-trichyeu">
       <?php
//        $strReplace = mb_strtolower($row['TRICHYEU'],"utf-8");
//        for($i=0;$i<count($arrSearch);$i++){
//        $strReplace = str_replace(mb_strtolower($arrSearch[$i],"utf-8"), '<em>'.$arrSearch[$i].'</em>', $strReplace);
//        }
//        echo $strReplace;
        ?>        
       </td>     
    </tr>  -->
    <tr>
        <td class="search-results-gadget">
            <a href="javascript:loadBook('<?=$row['ID_FOREIGN']?>','<?=$row['LOAI']?>','<?=$row['TEN'] ?>','<?=$row['MA']?>','<?=$row['SOLUONG_CL']?>');">Cho mượn</a>
            <a href="javascript:loadDetail(<?=$row['ID_FOREIGN']?>,<?=$row['LOAI']?>)"> - Xem chi tiết</a>
        </td>
    </tr>  
    </table>
    <br />
    <?php
    }
    }
    else {
        echo '<h3>Không tìm thấy kết quả nào.</h3>';
    }    
    ?>
</form>
<?=$this->paging?>
<?php
    if(count($this->data) < 3)
    {
    ?>
    <div style="height:400px;">
    </div>
    <?php
    }
    ?>
</div>
<!-- CHO MƯỢN -->

<div id='select-book' style="float:left;position:fixed;margin-left:620px;">
</div>
<script>
document.getElementById('searchContent').focus();
function back(){
    window.history.go(-1);
}
var title = "";
var code = "";
function loadDetail(id,loai){
    var JX_load = new Jx();
    JX_load.setParameter('id',id);
    JX_load.setParameter('loai',loai);
    JX_load.loadInto('select-book');
    JX_load.request('/admin/search/detail','POST');
}
function loadBook(masach,loai,ten,n_code,soluong){
    title = ten;
    code = n_code;
    var JX2 = new Jx();
    JX2.setParameter('step','1');
    JX2.setParameter('ma',masach);
    JX2.setParameter('soluong',soluong);
    JX2.setParameter('loai',loai);
    JX2.loadInto('select-book');
    JX2.success(fillInfo);
    JX2.request('/admin/search/index','POST');
}
function fillInfo(){
    var ten_html = "<strong> <font color='#004FA0'>Tên: </font>"+title+"</strong>";
    var code_html = "<strong> <font color='#004FA0'>Mã: </font>"+code+"</strong>";
    document.getElementById('title').innerHTML = ten_html;
    document.getElementById('code').innerHTML = code_html;
}
function fillInfoMuon(){
    document.getElementById('title_chomuon').value = title;
    document.getElementById('ma_chomuon').value = code;
}
</script>